var Monster = Class
		.extend({
			getFrame : function(index) {
				if (this.atacking == true) {
					if (this.currentFrame == 4) {
						this.currentFrame = 5;
						return;
					} else {
						this.currentFrame = 4;
						return;
					}
				}
				if (this.currentFrame < this.framesCount) {
					this.currentFrame++;

				} else {
					this.currentFrame = 0;
				}
			},

			getDeathFrame : function(index) {

				if (this.deathFrame <= this.deathFramesCount) {
					this.deathFrame++;
				} else {
					player.money += this.bounty;
					player.totalMoneyGained += this.bounty;
					monsters.splice(index, 1);

				}
			},
			draw : function(index) {
				var index = index;

				if (this.alive == true) {

					if (this.frameCounter == 5) {
						this.getFrame(index);
						this.frameCounter = 0;
					} else {
						this.frameCounter++;

					}
					// Monster
					ctx.drawImage(this.image,
									this.currentFrame
											* this.frameWidth, 0,
									this.frameWidth,
									this.frameHeigth,
									this.xCoord,
									this.yCoord,
									this.frameWidth
											* this.scale,
									this.frameHeigth
											* this.scale);
					// HealthBar
					ctx.strokeStyle = "black";
					ctx.strokeRect(this.xCoord, this.yCoord - 20, this.frameWidth * this.scale, 15);
					ctx.fillStyle = "red";
					ctx
							.fillRect(
									this.xCoord,
									this.yCoord - 20,
									(this.frameWidth
											* this.scale / this.maxHp)
											* this.HP, 15);
					if (this.headShot == true) {
						ctx.fillStyle = "white";
						ctx.fontStyle = "10px Impact";
						ctx.fillText("HEADSHOT!", this.xCoord
								+ this.frameWidth
								* this.scale + 10,
								this.yCoord);
						this.headShot = false;
					}
					if (this.atacking == false) {
						if (!this.bonus) {
							this.yCoord += 0.04;
							this.scale += 0.005;
						} else {
							monsters[index].xCoord += 2;
						}
					}

				} else {

					if (this.frameCounter == 5) {
						this.frameCounter = 0;
						this.getDeathFrame(index);
					} else {
						this.frameCounter++;
						ctx.drawImage(this.deathImage,
								this.deathFrame
										* this.deathFrameWidth, 0,
								this.deathFrameWidth,
								this.deathFrameHeigth,
								this.xCoord, this.yCoord,
								this.deathFrameWidth
										* this.scale,
								this.deathFrameHeigth
										* this.scale);
						if (this.headShot == true) {
							ctx.fillStyle = "white";
							ctx.fontStyle = "10px Impact";
							ctx.fillText("HEADSHOT!", this.xCoord
									+ this.frameWidth
									* this.scale + 10,
									this.yCoord);
							/*ctx.strokeStyle = 'red';
							ctx.strokeText("HEADSHOT!", this.xCoord
									+ this.frameWidth
									* this.scale + 10,
									this.yCoord);*/

						}
					}

				}
			}
		});




